import Vue from "vue"
import "normalize.css/normalize.css"
import "animate.css/animate.css"
import App from "./App.vue"
import router from "./router"
import store from "./store"
import echarts from "echarts"
import "viewerjs/dist/viewer.css"
import "./plugins/element.js"
import "@/directive"
import "./router/permission"
import "@/components"
import Viewer from "v-viewer"
import Router from "vue-router"
// import FileSaver from 'file-saver'
// import XLSX from 'xlsx'
// const Snap = require("imports-loader?this=>window,fix=>module.exports=0!snapsvg/dist/snap.svg.js");
Vue.use(Viewer, {
  defaultOptions: {
    zIndex: 9999
  }
})
Vue.config.productionTip = false
Vue.prototype.$echarts = echarts

const originalPush = Router.prototype.push // 解决点击同一路由时 报错
Router.prototype.push = function push (location) {
  return originalPush.call(this, location).catch(err => err)
}

Vue.prototype.hasAuthority = function (authorities) {
  if (!authorities) {
    return false
  }
  return authorities.split(",").some(item => {
    // return store.state.user.access.includes("ACTION_" + item)
  })
}

new Vue({
  router,
  store,
  render: function (h) {
    return h(App)
  },
  mounted () {
    document.dispatchEvent(new Event("render-event"))

    // 默认导航
    let data = [
      // {
      //   id: 6,
      //   pid: 0,
      //   name: "人工录入",
      //   url: "/manual",
      //   pIcon: "el-icon-s-order",
      //   children: [
      //     {
      //       id: 5,
      //       pid: 4,
      //       name: "人工录入列表",
      //       url: "entryList"
      //     }
      //   ]
      // },
      {
        id: 4,
        pid: 3,
        name: '标准规范',
        url: '/standard',
        pIcon: 'el-icon-folder',
        children: [
          {
            id: 19,
            pid: 18,
            name: '标准规范',
            url: 'standard',
            pIcon: 'el-icon-folder'
          },
          {
            id: 19,
            pid: 18,
            name: '测试页面',
            url: 'test',
            pIcon: 'el-icon-folder'
          }
        ]
      },
      // {
      //   id: 10,
      //   pid: 0,
      //   name: "任务监控",
      //   url: "/taskMonitoring",
      //   pIcon: "el-icon-wallet",
      //   children: [
      //     {
      //       id: 11,
      //       pid: 10,
      //       name: "任务监控",
      //       url: "11"
      //     }
      //   ]
      // }
    ]
    store.commit("SET_NAVBAR", data)
  }
}).$mount("#app")
